package com.speily.current.wait_notify.product_consumer;


import org.junit.Test;

/**
 * @Auther: SPL
 * @Date: 2019-07-30 16:21
 * @Description: -
 */
public class TestMain {

    @Test
    public void test() {
        // 仓库对象
        Storager storager = new MyStorger();

        // 生产者对象
        Producer p1 = new Producer(storager);
        Producer p2 = new Producer(storager);
        Producer p3 = new Producer(storager);
        Producer p4 = new Producer(storager);
        Producer p5 = new Producer(storager);
        Producer p6 = new Producer(storager);
        Producer p7 = new Producer(storager);

        // 消费者对象
        Consumer c1 = new Consumer(storager);
        Consumer c2 = new Consumer(storager);
        Consumer c3 = new Consumer(storager);

        // 设置生产者产品生产数量
        p1.setNum(1);
        p2.setNum(1);
        p3.setNum(1);
        p4.setNum(1);
        p5.setNum(1);
        p6.setNum(1);
        p7.setNum(8);

        // 设置消费者产品消费数量
        c1.setNum(5);
        c2.setNum(2);
        c3.setNum(3);

        // 线程开始执行
        c1.start();
        c2.start();
        c3.start();

        p1.start();
        p2.start();
        p3.start();
        p4.start();
        p5.start();
        p6.start();
        p7.start();
    }

}
